package gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;

import client.ClientConsole;

/**Enables the library manager to choose which report to produce */
public class ProduceReportWindow extends JPanel implements ActionListener{
	/** GUI panels for design*/
	JPanel mainPanel,topPanel,bottomPanel;
	JButton choose,back;
	/** combo box for choosing reports*/
	JComboBox opt;
	/** holds all report options types*/
	String[] reportOpt={"Periodic Report","Lends Report","Dealys on return"};
	
	/**Default constructor-Generates and creates the produce report window*/
	public ProduceReportWindow()
	{
		super();
		setLayout(new BorderLayout());
		mainPanel=new JPanel(new BorderLayout());
		opt=new JComboBox(reportOpt);
		opt.setSelectedIndex(0);
		choose=new JButton("Choose Report");
		topPanel=new JPanel();
		topPanel.add(opt);
		topPanel.add(choose);
		mainPanel.add(topPanel,BorderLayout.CENTER);
		bottomPanel=new JPanel();
		back=new JButton("Back");
		bottomPanel.add(back);
		choose.addActionListener(this);
		back.addActionListener(this);
		add(mainPanel,BorderLayout.CENTER);
		add(bottomPanel,BorderLayout.SOUTH);
	}

	//Handles user's clicks on buttons
	@Override
	public void actionPerformed(ActionEvent ae) {
		if (ae.getSource()==choose)
		{
			if (opt.getSelectedIndex()==0)
			{
				this.setVisible(false);
				PeriodicReportWindow prw=new PeriodicReportWindow();
				ClientConsole.aFrame.setContentPane(prw);
				
			}
			else if (opt.getSelectedIndex()==2)
			{
				this.setVisible(false);
				LateInReturnReportWindow lir=new LateInReturnReportWindow();
				ClientConsole.aFrame.setContentPane(lir);
				
			}
			else if (opt.getSelectedIndex()==1)
			{
				this.setVisible(false);
				LendsReportWindow lrw=new LendsReportWindow();
				ClientConsole.aFrame.setContentPane(lrw);
			}
			
			
		}
		if (ae.getSource()==back)
		{
			LibraryManagerWindow lmw=new LibraryManagerWindow();
			this.setVisible(false);
			ClientConsole.aFrame.setContentPane(lmw);
			
			
		}
	}
}
